<template>
  <div class="app-container">
    <el-card class="box-card">
      <el-form ref="form" :model="form" >
            <el-descriptions  title="产品交付信息" style="text-align: center" :column="2" border >
              <el-descriptions-item label="出厂唯一标识码"  label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >{{ form.identificationCode}}</el-descriptions-item>
              <el-descriptions-item label="产品类型"   label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >{{ form.productType}}</el-descriptions-item>
              <el-descriptions-item label="特征号"  label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.characteristicNum}}</el-descriptions-item>
              <el-descriptions-item label="数量"  label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.quantity}}</el-descriptions-item>
              <el-descriptions-item label="批次号"  label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.batchNum}}</el-descriptions-item>
              <el-descriptions-item label="企业"  label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.partNumber}}</el-descriptions-item>
              <el-descriptions-item label="合同编号"  label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.contractNo}}</el-descriptions-item>
            </el-descriptions>
            <br/>
            <el-descriptions  title="提交单信息" :column="2" border >
             <el-descriptions-item label="提交单号" label-class-name="my-label"   :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.submissionNo}}</el-descriptions-item>
              <el-descriptions-item label="提交单拍照" label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle"><el-button type="text" size="medium" @click="downloadEvt">查看照片</el-button></el-descriptions-item>
              <el-descriptions-item label="验收人" label-class-name="my-label"   :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.acceptedPerson}}</el-descriptions-item>
              <el-descriptions-item label="验收时间" label-class-name="my-label"   :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.acceptedTime}}</el-descriptions-item>
            </el-descriptions>
             <br/>
              <el-descriptions  title="上传合格证信息" :column="2" border >
              <el-descriptions-item label="拍照上传合格证" label-class-name="my-label"    :contentStyle='contentStyle' :labelStyle="labelStyle"><el-button type="text" size="medium" @click="downloadEvt1">查看照片</el-button></el-descriptions-item>
                <el-descriptions-item label="备注" label-class-name="my-label"   :contentStyle='contentStyle' :labelStyle="labelStyle">{{ form.remark}}</el-descriptions-item>
              </el-descriptions>
            <br/>
      </el-form>
      <br/>
      <div style="float:right; margin-bottom: 15px;">
        <el-button @click="viewCancel">返 回</el-button>
      </div>
    </el-card>
  </div>
</template>
<script>
  import { listDelivery, getDelivery, delDelivery, addDelivery, updateDelivery } from "@/api/module/cjl/delivery";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import watermark from "watermark-dom";
export default {
  name: "Contract",
  dicts: ['sys_job_status','yh_contract_type','yh_contract_declare','yh_item_classification','yh_representative_office','yh_equipment_contractor_unit','yh_contractor_unit'],
  components: { Treeselect },
  data() {
    return {
      contentStyle: {
        'width': '400px',
      },
      //label样式
      labelStyle: { 'width': '140px','color': '#000000','text-align': 'right', },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 部门树选项
      deptOptions: undefined,
      // 合同台账表格数据
      contractList: [],
      // 岗位选项
      postOptions: [],
      // 部门名称
      deptName: undefined,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sequenceNumber: null,
        projectName: null,
        contractType: null,
        equipName: null,
        equipVersion: null,
        quantity: null,
        technicalConditions: null,
        contractNo: null,
        contractDeclare: null,
        representativeOffice: null,
        regulation: null,
        projectType: null,
        purchasingDepartment: null,
        taskConfirmationTime: null,
        executiveStaff: null,
        taskStatus: null,
        completionTime: null,
        note: null,
        paymentTime: null,
        managementAgency: null,
        equipmentContractorUnit: null,
        scheduleTarget: null,
        contractorUnit: null,
        matchingContractNo: null,
        generalRepresentativeOffice: null,
        generalContractorUnit: null,
        projectManagementAgency: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 表单参数
      form: {},
      // 用户查询参数
      view:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
    };
  },
  mounted() {
    watermark.load({ watermark_txt: "  "   });
  },
  created() {
    const id = this.$route.query.id;
    if (id) {
      // 获取表详细信息
      getDelivery(id).then(res => {
        this.form = res.data;
      });
    }
  },
  methods: {
    downloadEvt(url, fileName = '提交单照片') {
      const el = document.createElement('a');
      el.style.display = 'none';
      el.setAttribute('target', '_blank');
      fileName && el.setAttribute('download', fileName);
      url= this.$store.state.user.ipaddress+this.form.submitPhoto
      el.href = url;
      console.log(el);
      document.body.appendChild(el);
      el.click();
      document.body.removeChild(el);
    },
    downloadEvt1(url, fileName = '合格证照片') {
      const el = document.createElement('a');
      el.style.display = 'none';
      el.setAttribute('target', '_blank');
      fileName && el.setAttribute('download', fileName);
      url= this.$store.state.user.ipaddress+this.form.uploadCertificate
      el.href = url;
      console.log(el);
      document.body.appendChild(el);
      el.click();
      document.body.removeChild(el);
    },
    /** 关闭按钮 */
    viewCancel() {
      const id = this.$route.query.id;
      getDelivery(id).then(response => {
        this.form = response.data;

      });
      const obj = { path: "/hetong/cjldelivery", query: {id} };
      this.$tab.closeOpenPage(obj);
  },

    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
  }
};
</script>
<style lang="scss" scoped>



</style>
